package com.els;

import java.util.List;

import org.elasticsearch.action.delete.DeleteRequestBuilder;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.update.UpdateRequestBuilder;
import org.elasticsearch.client.Client;
import org.elasticsearch.index.query.QueryBuilder;

import com.bridge.domain.PropertyVO;
import com.els.domain.QueryRespVO;
import com.google.gson.JsonObject;

public interface ElsConnection{
	//创建Client，建立Client链接
	public boolean buildClient();
	//单进程Bulk索引接口
	public int singleBulkIndex(String index,String type,List<JsonObject> jsonList,String id);
	//含parent的Bulk索引接口
	public int singleBulkIndex(String index,String type,List<JsonObject> jsonList,String id,String parent);
	//根据requestList进行Bulk索引接口，配合prepare接口使用（除prepareSearch）
	public <T> int singleBulk(List<T> requestList);
	//插入记录接口
	public String insertOne(String indexName, String typeName,String id, JsonObject obj);
	//删除记录接口
	public boolean deleteOne(String indexName, String typeName,String _id);
	//更新记录接口
	public boolean updateOne(String indexName, String typeName,String _id, JsonObject obj);
	//生成插入记录请求接口
	public IndexRequestBuilder prepareInsertOne(String indexName, String typeName,String id, JsonObject obj);
	//生成删除记录请求接口
	public DeleteRequestBuilder prepareDeleteOne(String indexName, String typeName,String _id);
	//生成更新记录请求接口
	public UpdateRequestBuilder prepareUpdateOne(String indexName, String typeName,String _id, JsonObject obj);
	//生成查询请求接口
	public SearchRequestBuilder prepareSearch(String indexName, String typeName,QueryBuilder queryBuilder);
	//单例选取接口
	public JsonObject selectOne(String indexName, String typeName,String id, JsonObject obj);
	//查询全部记录接口，大数据索引谨慎使用
	public List<JsonObject> queryAll(String indexName, String typeName);
	//按QueryBuilder的查询全接口，大数据索引谨慎使用
	public List<JsonObject> queryAllByQueryBuilder(String indexName, String typeName,QueryBuilder queryBuilder);
	//按QueryBuilder进行翻页查询接口
	public List<JsonObject> queryByQueryBuilder(String indexName, String typeName,QueryBuilder queryBuilder,int from,int size);
	//执行搜索请求，配合prepareSearch使用
	public QueryRespVO executeQueryRequest(SearchRequestBuilder srb);
	//获取记录总数
	public long getTotal(String index,String type);
	//增加type
	public boolean newType(String index,String type,List<PropertyVO> mappings);
	//增加index
	public boolean newIndex(String index,int shardSize,int replicaSize);
	//关闭client
	public void closeClient();
	//获取client
	public Client getClient();
}
